package com.kancy.streamplus.config;

import com.kancy.streamplus.channel.DynamicChannelResolver;
import com.kancy.streamplus.channel.PollingInputChannel;
import com.kancy.streamplus.channel.PollingMessageDispatcher;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;

/**
 * PollingMessageDispatcherAutoConfiguration
 *
 * @author kancy
 * @date 2020/3/22 23:48
 */
@EnableBinding({PollingInputChannel.class})
@ConditionalOnProperty(prefix = "streamplus.dispatcher", name = "enabled", havingValue = "true")
public class PollingMessageDispatcherAutoConfiguration {

    @Bean
    public PollingMessageDispatcher pollingMessageDispatcher(ApplicationContext context, DynamicChannelResolver dynamicChannelResolver){
        return new PollingMessageDispatcher(context, dynamicChannelResolver);
    }
}
